using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// 链接方式，将外设与终端链接起来
public abstract class LinkStrategy : IElementBase
{
    public string LinkStrategyName { get; set; }
    public abstract string SendData(Peripheral peripheral, Termina termina);
    public string GetElementName()
    {
        return LinkStrategyName;
    }
}

// 有线连接
public class WiredConnection : LinkStrategy
{
    public WiredConnection()
    {
        LinkStrategyName = "WiredConnection";
    }
    
    
    public override string SendData(Peripheral peripheral, Termina termina)
    {
        // 移动设备不能有线链接到外设
        if (termina.TerminaType == eTerminaType.Computer)
        {
            var msg = $"{peripheral.PeripheralName} 连接方式为 {LinkStrategyName}";
            return termina.ReceivedData(msg);
        }
        else
        {
            var str = $"{peripheral.PeripheralName} 不能使用有线连接到 {termina.TerminaType} 终端";
            return str;
        }
        
    }
}

// 无线连接
public class WirelessConnection : LinkStrategy
{

    public WirelessConnection()
    {
        LinkStrategyName = "WirelessConnection";
    }
    
    public override string SendData(Peripheral peripheral, Termina termina)
    {
        if (termina.TerminaType == eTerminaType.None)
        {
            Debug.Log($"[WirelessConnection] SendData connetion error {termina.TerminaType}");
            return null;
        }
        var msg = $"{peripheral.PeripheralName} 连接方式为 {LinkStrategyName}";
        return termina.ReceivedData(msg);
        
    }
}